<?php
class KarmaActionController extends ActionController{

    public function run(){
        
        $userMapper = new UserMapper();
        
        if (isset($this->params['reduction'])){
                $userMapper->reductionKarma();
        }
                
        if($this->isPost()) {
            $data = $this->getPost();
            if($this->user->isUser($data['userID'])) {
                $this->view->karma = $this->user->karma?$this->user->karma:0;
            } else {
                $this->view->karma = $userMapper->addAndGetKarma($data, $this->user->id);
            }
        }
        
        $this->view->setRenderTemplate('karma.phtml');
        
    }
}

?>